package com.ftg.shopping.shopcar.service;

import com.ftg.shopping.config.LayuiPage;
import com.ftg.shopping.shopcar.entity.sp_cartshop;
import com.ftg.shopping.shopcar.mapper.shopcarMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class shopcarService {

    @Autowired
    shopcarMapper shopcarMapper;

    public LayuiPage<sp_cartshop> showAll4(int page,int limit){
        String userid = null;
        LayuiPage layuiPage=new LayuiPage();
        int end = Integer.valueOf(limit);
        int start = (Integer.valueOf(page) - 1) * end;

        if(null != userid && !"".equals(userid)){
            layuiPage.setData(shopcarMapper.showAll3(start,end,userid));
            layuiPage.setCount(shopcarMapper.showAll3(start,end,userid).size());
        }else{
            layuiPage.setData(shopcarMapper.showAll(start,end));
            layuiPage.setCount(shopcarMapper.showAll2().size());
        }
        return layuiPage;
    }

    public int deleteshopcar(int id){
        return shopcarMapper.deleteshopcar(id);
    }
}
